package com.youyunsoft.commons.nested_list;

import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.youyunsoft.commons.BaseActivity;
import com.youyunsoft.commons.R;
import com.youyunsoft.commons.databinding.ActivityNestedListBinding;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class NestedListActivity extends BaseActivity {

    ActivityNestedListBinding binding;

    List<ParentBean> mdatas = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_nested_list);


        ParentAdapter adapter = new ParentAdapter();

        String[] childs = {"aaa", "bbb", "ccc"};

        for (int i = 0; i < 20; i++) {
            ParentBean parentBean = new ParentBean();
            parentBean.setTag("Parent " + i);
            parentBean.setChildren(Arrays.asList(childs));
            mdatas.add(parentBean);
        }


        binding.list.setAdapter(adapter);

    }

    class ParentAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return mdatas.size();
        }

        @Override
        public Object getItem(int position) {
            return mdatas.get(position);
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {


            return convertView;
        }
    }

    class ChildAdapter extends BaseAdapter{
        @Override
        public int getCount() {
            return 0;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            return null;
        }
    }


}
